<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\dkgzh\controller;
use cmf\lib\Upload;
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;

/**
 * Description of ImgController
 *
 * @author PVer
 */
class ImgController extends HomeBaseController {

    //put your code here
    public function upload() {
        
    }
    public function getQiniuUploadInfo(){
        $pluginClass = cmf_get_plugin_class('Qiniu');
        $plugin = new $pluginClass();
        $config = $plugin->getConfig();
        $upManager = new UploadManager();
        $auth      = new Auth($config['accessKey'], $config['secretKey']);
        $token     = $auth->uploadToken($config['bucket']);
        if (!empty($config)) {
            $result = array(
                'url'   =>  "http://upload.qiniu.com/",
                'token'=>$token,
                'storageRoot'   =>  $config['protocol'] . '://' . $config['domain'] . '/'
            );
            returnData($result);
        }else{
            returnError();
        }
    }

}
